/**
 * @ author: 汪孟苹
 */
define(["jquery","bbcare","comm/datatable/datatable","bch/app/vaccine/vaccineMiss.event"],function($,$bb,$datatable,$event){
	var servers = {};
	var URL = $bb.baseUrl("followapp");
    
    /**
     * 入参
     */
    var inParams = function(args){
        var params = $bb.getPageParams();
        var arg = {
            "args": JSON.stringify(args),
            "busiType":params.busiType,
            "showFlag":"1",
        };
        if( $.trim($('#userName').val()) ) $.extend(arg,{"userName": $.trim($('#userName').val())});
        if( $.trim($('#phoneNo').val()) ) $.extend(arg,{"phoneNo": $.trim($('#phoneNo').val())});
        if( $.trim($('#inoculationCard').val()) ) $.extend(arg,{"inoculationCard": $.trim($('#inoculationCard').val())});
        if( $.trim($('#taskName').val()) ) $.extend(arg,{"taskName": $.trim($('#taskName').val())});
        if( $.trim($('#beginDate').val()) ) $.extend(arg,{"beginDate": $.trim($('#beginDate').val())});
        if( $.trim($('#endDate').val()) ) $.extend(arg,{"endDate": $.trim($('#endDate').val())});
        var data = JSON.stringify({
            data: arg
        });
        return data;
    }
    /**
     * 出参
     */
    var outParams = function(data){
        return data.rows;
    }
    /**
     * columns
     */
    var columnsData = function(){
        var columnsArr = [
            {"data":'inoculationCard'},
            {"data":'userName'},
            {"data":'birthday'},
            {"data":'taskName'},
            {"data":'lostDate'},
            {"data":'nodeName'},
            {"data":'phoneNo'},
            {"data":"sendType"},
            /*{
                "data":null,
                "className":"operate"
            },*/
        ];
        return columnsArr;
    }
    /**
     * 行绘制回调函数
     */
    var rowCallback = function(row, data, index) {
        // 判断条件后期替换
        var h = data.sendStatus == "提醒" ? '<div class="btn-solid btn-solid-green">提醒</div>':'已提醒';
        $('td.operate', row).html(h);
        $("td.operate .btn-solid-green",row).unbind("click");
        $("td.operate .btn-solid-green",row).click($event.onMissWarn);
    };
    /**
     * 初始化完成之后的回调函数
     */
    var initComplete = function(setting,json){
        var id = $(".layout-bottom table").attr("id");
        $("#" + id).prev("div.row").remove();
        $("#serchBtn").bind("click",function(){
            $datatable.table.api().ajax.reload();  // 出发dt的重新加载数据的方法
            var args = $datatable.table.api().ajax.params();   //获取dt请求参数
        });
    }
    /**
     * 获取datatable里的options
     */
    servers.getOptions = function(){
        var sessionId = $bb.getSessionStorage("sessionId");
        var options = {
            "ajax": {
                "url": URL + "ctrl/VaccineInfo/selectUserCpTaskLost?sessionId=" + sessionId,
                "data": inParams,
                "dataSrc": outParams
            },
            "columns": columnsData(),
            //"rowCallback": rowCallback,
            "initComplete": initComplete,
        };
        return options;
    }

	return servers;
});